<?php
require_once("include/setup.php");
require_once(CLASS_PATH.'document.class.php');
LoginHelper::controlAccess(array('type_droits_user' => '>=1'));

$user = LoginHelper::getUserConnected();

$filtres = array(
	'withUser' => true,
	'orderby' => 'last_update desc',
	'id_user' => 0
);

if ($user->type_droits_user == 1) {
	$filtres['type_partage'] = 0;
}

if (!empty($_POST['filtres'])) {
	foreach ($_POST['filtres'] as $name => $value) {
		$filtres[$name] = $value;
	}
}

$documents = Document::getDocuments($filtres);

$users = array();
foreach ($documents as $d) {
	$u = $d->user;
	if (!empty($u)) {
		$users[$u->id_user] = $u;
	}
}



$v = new JapwordView();
$v->assign('documents', $documents);
$v->assign('filtres', $filtres);
$v->assign('documents_users', $users);
$v->display('document_list.html');
?>